//========encoding:utf-8=========
/*
 * @describe:  三目运算符
 * @author:mhao
 * @copyright:chinasoft.cn
 * @date:2020年3月18日   下午8:12:45
 */
package edu.chinasoft.handle;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import edu.chinasoft.pojo.User;
@Controller("handler02")
@RequestMapping("/handler02")
public class Handler02 {
	private Logger logger = LoggerFactory.getLogger(Handler02.class);
	@RequestMapping("/method01.do")
	public @ResponseBody() String method01(String user_name,String user_password) throws IOException {
		// TODO Auto-generated method stub
		logger.info("handler02>>>method01 start ……");
		//调用服务层方法，返回结果
		User result = new User(user_name,user_password);
		logger.info("handler02>>>method01 end ……");
		return "name:"+result.getName()+";password:"+result.getPassword()+"";
	}
	@RequestMapping("/method02.do")
	public String method02(String user_name,String user_password,ModelMap modelMap) throws IOException {
		// TODO Auto-generated method stub
		logger.info("handler02>>>method02 start ……");
		User user = new User(user_name,user_password);
		//把服务层返回的结果保存到request域里
		modelMap.addAttribute("user", user);
		//实现页面跳转(请求转发所要跳转的页面)
		String result="/loginsuccess02";
		logger.info("handler02>>>method02 end ……");
		return result;
	}
	@RequestMapping("/method03.do")
	public String method03(String user_name,String user_password,ModelMap modelMap) throws IOException {
		// TODO Auto-generated method stub
		logger.info("handler02>>>method03 start ……");
		User user = new User(user_name,user_password);
		//把服务层返回的结果保存到request域里
		modelMap.addAttribute("user", user);
		//实现页面跳转(请求转发所要跳转的页面)
		String result="/jsp/loginsuccess02.jsp";
		logger.info("handler02>>>method03 end ……");
		return result;
	}
	@RequestMapping("/method04.do")
	public String method04(String user_name,String user_password,ModelMap modelMap) throws IOException {
		// TODO Auto-generated method stub
		logger.info("handler02>>>method04 start ……");
		User user = new User(user_name,user_password);
		//把服务层返回的结果保存到request域里
		modelMap.addAttribute("user", user);
		//实现页面跳转(请求重发)
		//String result="redirect:/jsp/loginsuccess02.jsp";
		String result="forward:/jsp/loginsuccess02.jsp";
		logger.info("handler02>>>method04 end ……");
		return result;
	}
}
